import http from '@/utils/axios'
import qs from 'qs'

export default {
  searchTree(name) {
    return http({
      url: `/management-function-menu/client/parentList?name=${name}`,
      method: 'get',
    })
  },
  getTree(parentId) {
    return http({
      url: `/management-function-menu/client/getChildren?parentId=${parentId}`,
      method: 'get',
    })
  },
  getTableData(prams) {
    if (!prams.appKey) {
      delete prams.appKey
    }
    if (!prams.code) {
      delete prams.code
    }
    if (!prams.name) {
      delete prams.name
    }
    delete prams.total
    return http({
      url: `/management-function-menu/client/list`,
      method: 'get',
      params: prams,
    })
  },
  //获得所属应用选项
  getAppTypeList() {
    return http({
      url: `/management-application/app/getClientList`,
      method: 'get',
    })
  },
  create(prams) {
    return http({
      url: `/management-function-menu/client/insert`,
      method: 'post',
      data: prams,
    })
  },
  update(prams) {
    return http({
      url: `/management-function-menu/client/update`,
      method: 'post',
      data: prams,
    })
  },
  getEditDetail(id) {
    return http({
      url: `/management-function-menu/client/getById?id=${id}`,
      method: 'get',
    })
  },
  getTreeNodeDetail(id) {
    return http({
      url: `/management-function-menu/function/getById?id=${id}`,
      method: 'get',
    })
  },
  delete(prams) {
    return http({
      url: `/management-function-menu/client/delete?id=${prams.id}`,
      method: 'post',
    })
  },
}
